//企业简历详情基本信息
import React, {Component} from 'react'
import {ScrollView, Text, TouchableOpacity, View,} from 'react-native';

import {Cresumebutton_Style as styles} from '../../../../styles';
import Modal from 'react-native-modal';
import Autoinput2 from '../../../util/inputUtil2';
import {getSize} from '../../../util/sizeUtil'
import {PostionSendDelayAction} from "../../../actions/postion_c";
import {connect} from "react-redux";
import {bindActionCreators} from "redux";

let Dimensions = require('Dimensions');
let width = Dimensions.get('window').width;

class Cresume_button2 extends Component {
    constructor(props) {
        super(props);
        this.state = {
            msg: '',
            isModalVisible: false,
        };
    }

    _showModal2 = () => this.setState({isModalVisible2: true});
    _hideModal2 = () => this.setState({isModalVisible2: false});


    render() {
        return (
            <View>

                <TouchableOpacity activeOpacity={1} onPress={this._showModal2}
                                  style={[styles.but_in, {width: width * 0.42}]}>
                    <Text style={styles.but_text}>
                        暂不合适
                    </Text>
                </TouchableOpacity>

                <Modal isVisible={this.state.isModalVisible2}
                       animationIn={'slideInLeft'}
                       animationOut={'slideOutRight'}>
                    <View style={styles.skill_modal}>
                        <Text style={styles.skill_text2}>请输入不合适理由</Text>

                        <ScrollView style={styles.rout} ref="sv2">
                            <View style={styles.but_textout4} ref="v2">
                                <Autoinput2
                                    style={[styles.inputname, {width: width * 0.7}]}
                                    function={this.setMsg.bind(this)}
                                    onChange={this.gooo.bind(this)}
                                    onFocus={this.gooo.bind(this)}
                                />
                            </View>
                        </ScrollView>

                        <View style={styles.skill_yesno}>
                            <TouchableOpacity style={styles.skill_yesout}>
                                <Text onPress={() => {
                                    this._hideModal2();
                                    this.props.actions.PostionSendDelayAction({
                                        sendId: this.props.sendId,
                                        msg: this.state.msg,
                                    });
                                    this.props.navigation.goBack();
                                }}
                                      style={styles.skill_yes}>确定</Text>
                            </TouchableOpacity>
                            <TouchableOpacity style={styles.skill_noout}>
                                <Text onPress={this._hideModal2} style={styles.skill_no}>取消</Text>
                            </TouchableOpacity>
                        </View>
                    </View>

                </Modal>

            </View>
        )
    }


    //拒绝理由
    setMsg(msg) {
        this.setState({msg: msg});
    }

    gooo() {
        getSize(this.refs.v2).then(res => {
            this.refs.sv2.scrollTo({x: 0, y: (res.height + res.pageY), animated: true})
        })
    }
}

//20171220-王继顺
//组合action
let actions = {
    PostionSendDelayAction,
};
//连接state到props
const mapStateToProps = state => {
    return {
        PostionSendDelayReducer: state.PostionSendDelayReducer //自己的reducers
    }
};
//连接action
const mapDispatchToProps = (dispatch) => {
    return {
        actions: bindActionCreators(actions, dispatch)
    }
};
//导出组合好的组件(组合后状态改变重新渲染组合组件的页面)
export default connect(
    mapStateToProps, mapDispatchToProps
)(Cresume_button2);